<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Edit extends CI_Controller {
    
    public function __construct()
    {
            parent::__construct();
            $this->load->model('cities_model');
    }    
    
    public function cities( $city_id=0 )
    {     
        
        $builder = new CI_TemplateBuilder();
        
            $this->load->helper('form');
            $this->load->library('form_validation');
            
            $this->form_validation->set_rules('name', 'name', 'required');
            $this->form_validation->set_rules('zip', 'zip', 'required');            
            $this->form_validation->set_rules('lng', 'lng', 'required|decimal');            
            $this->form_validation->set_rules('lat', 'lat', 'required|decimal');            
            
            if ($this->form_validation->run() === FALSE)
            {
                $data['title'] = 'Edit City'; 
                $data['city_row'] = $this->cities_model->get_row( $city_id );
                $builder->admin_template_builder('cities/edit' , $data);
            }
            else
            {
                $this->cities_model->edit_city();
                $info = 'Succesfully edit a city';
                redirect('admin/show/cities/'.$info, 'location', 301);
            }                                              
                                        
          
          
    }
        
        
    
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */